package com.java.shop.product.web;

import com.java.shop.product.entity.CategoryEntity;
import com.java.shop.product.service.CategoryService;
import com.java.shop.product.webvo.Catelog2Vo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class IndexController {
    @Autowired
    CategoryService categoryService;


    @GetMapping({"/","index.html","index.htm"})
    public String indexPage(Model model){
        // TODO index页面页码，面包屑 未处理
        List<CategoryEntity> cate1Level = categoryService.getCatelog1();
        model.addAttribute("cate1Level",cate1Level);
        return "index";
    }

    @ResponseBody
    @GetMapping("/index/catalog.json")
    public Map<String,List<Catelog2Vo>> getCatalogJson(){
        return categoryService.getCatalogJson();
    }


    @ApiOperation("压力测试简单服务")
    @ResponseBody
    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }


}
